package indi.wshape1.takeawaydeliveryinfo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import indi.wshape1.takeawaydeliveryinfo.mapper.BlockMapper;
import indi.wshape1.takeawaydeliveryinfo.pojo.Block;
import indi.wshape1.takeawaydeliveryinfo.service.BlockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Wshape1
 * @description 针对表【block】的数据库操作Service实现
 * @since 2023-01-17 12:57:25
 */
@Service
public class BlockServiceImpl extends ServiceImpl<BlockMapper, Block>
        implements BlockService {


    @Autowired
    @SuppressWarnings("all")
    private BlockMapper blockMapper;

    @Override
    public List<String> getBlockNameList() {
        return blockMapper.selectBlockNameList();
    }

    @Override
    public List<Block> getListByKeyword(String keyword) {
        QueryWrapper<Block> queryWrapper = new QueryWrapper<>();
        queryWrapper.and((q) -> q.like("block_name", keyword)
                        .or()
                        .like("info", keyword))
                .ne("block_name", "null");
        return list(queryWrapper);
    }
}




